package configmap

import (
	"gitee/yinlai/kms-backend/controllers"
	"gitee/yinlai/kms-backend/utils/logs"
	"github.com/dotbalo/kubeutils/kubeutils"
	"github.com/gin-gonic/gin"
)

func Get(r *gin.Context) {
	logs.Debug(nil, "获取Configmap详情")
	var info controllers.Info

	kubeconfig := controllers.NewInfo(r, &info, "获取成功")
	// 使用kubeUtils 接口实现资源创建
	var kubeUtilser kubeutils.KubeUtilser
	instance := kubeutils.NewConfigMap(kubeconfig, nil)
	kubeUtilser = instance
	info.Get(r, kubeUtilser)
}

//func Get(r *gin.Context) {
//	logs.Debug(nil, "获取Pod详情")
//
//	clientset, basicInfo, err := controllers.BasicInit(r, nil)
//	returnData := config.ReturnData{}
//	if err != nil {
//		returnData.Message = err.Error()
//		returnData.Status = 400
//		r.JSON(http.StatusOK, returnData)
//		return
//	}
//	pod, err := clientset.CoreV1().Pods(basicInfo.Namespace).Get(context.TODO(), basicInfo.Name, metav1.GetOptions{})
//	if err != nil {
//		logs.Error(map[string]interface{}{"id": basicInfo.ClusterId, "msg": err.Error()}, "获取Pod详情失败")
//		msg := "获取Pod详情失败：" + err.Error()
//		returnData.Status = 400
//		returnData.Message = msg
//	} else {
//		returnData.Message = "获取成功"
//		returnData.Status = 200
//		returnData.Data = make(map[string]interface{})
//		returnData.Data["item"] = pod
//	}
//	r.JSON(http.StatusOK, returnData)
//}
